home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 February / WN_129_CD.iso / Windows / Extensions Firefox / SwitchProxy Tool / switchproxy_1.3.1.xpi / install.js next >
Encoding:
Text File  |  2004-11-09  |  2.0 KB  |  60 lines

  1.  
  2. const gName            = "Switch Proxies";
  3. const gAuthor        = "Jeremy Gillick";
  4. const gRegKey        = "/JeremyGillick/SwitchProxies";
  5. const gVersion        = "1.3";
  6. const gJar            = "switchproxy.jar";
  7.  
  8. var    error             = null;
  9. var oFolder            = getFolder("Current User", "chrome");
  10. var iContentFlag    = CONTENT | PROFILE_CHROME;
  11. var iLocaleFlag        = LOCALE | PROFILE_CHROME;
  12.  
  13. //Install in App or Profile?
  14. var existsInApplication = File.exists(getFolder(getFolder("chrome"), gJar));
  15. var existsInProfile     = File.exists(getFolder(oFolder, gJar));
  16. if(existsInApplication || (!existsInProfile && !confirm("Do you want to install the extension into your profile folder?\n(Cancel will install into the application folder)")))
  17. {
  18.     iContentFlag    = CONTENT | DELAYED_CHROME;
  19.     iLocaleFlag        = LOCALE | DELAYED_CHROME;
  20.     oFolder         = getFolder("chrome");
  21. }
  22.  
  23. //Uninstall Existing
  24. if(existsInApplication || existsInProfile)
  25.     uninstall(gRegKey);
  26.  
  27. //Init
  28. initInstall(gName, gRegKey, gVersion);
  29. setPackageFolder(oFolder);
  30. error = addFile(gAuthor, gVersion, "chrome/"+ gJar, oFolder, null);
  31.  
  32. //Register
  33. if(error == SUCCESS){
  34.  
  35.     registerChrome(iContentFlag, getFolder(oFolder, gJar), "content/");
  36.     registerChrome(iLocaleFlag, getFolder(oFolder, gJar), 'locale/en-US/');
  37.     registerChrome(iLocaleFlag, getFolder(oFolder, gJar), 'locale/fr-FR/');
  38.     registerChrome(iLocaleFlag, getFolder(oFolder, gJar), 'locale/it-IT/');
  39.     registerChrome(iLocaleFlag, getFolder(oFolder, gJar), 'locale/is-IS/');
  40.     
  41.     error = performInstall(); //Install
  42.     
  43.     if(error != SUCCESS && error != 999){
  44.         switch(error){
  45.             case -215:
  46.                 alert("The installation of the extension failed.\nOne of the files being overwritten is read-only.");
  47.                 break;
  48.             case -235:
  49.                    alert("The installation of the extension failed.\nThere is insufficient disk space.");
  50.                 break;
  51.             default: 
  52.                 alert("The installation of the extension failed.\nThe error code is: " + error);
  53.         }
  54.         cancelInstall(error);
  55.     }
  56. }
  57. else{
  58.     alert("The installation failed.\n" + error);
  59.     cancelInstall(error);
  60. }